﻿//-----------------------------------------------------------------------
// <copyright file="AboutBox.cs" company="n.a.">
//     Copyright Dave999. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "To be returned to .")]
[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1601", Justification = "To be returned to .")]

namespace DbView
{
	using System;
	using System.IO;
	using System.Reflection;
	using System.Windows.Forms;
	using System.Diagnostics;

// ...
	public partial class AboutBox : Form
	{
		// see http://stackoverflow.com/questions/64602/what-are-differences-between-assemblyversion-assemblyfileversion-and-assemblyin
		public AboutBox()
		{
			this.InitializeComponent();

			// string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
			string version = GetInformationalVersion(Assembly.GetExecutingAssembly());
			DateTime buildDate = new FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime;

			//this.lblVersion.Text += version.Replace(".0.0", string.Empty); // not last two levels
			this.lblVersion.Text += version;
			this.lblBuild.Text += buildDate.ToLongDateString() + " " + buildDate.ToShortTimeString();
		}

		// credit to http://stackoverflow.com/questions/7770068/get-the-net-assemblys-assemblyinformationalversion-value
		string GetInformationalVersion(Assembly assembly) {
			return FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion;
		}

		private void BtnOk_Click(object sender, EventArgs e)
		{
			this.Close();
		}

		private void LblBanner_Click(object sender, EventArgs e)
		{
		}

		private void LinkCodeplex_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			string url = "http://dbviewsharp.codeplex.com";

			ProcessRunner pr = new ProcessRunner(url);
			pr.ShellExec(string.Empty);

			this.linkCodeplex.LinkVisited = true;
		}

		private void LinkExpressProfiler_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			string url = "http://ExpressProfiler.codeplex.com";

			ProcessRunner pr = new ProcessRunner(url);
			pr.ShellExec(string.Empty);

			this.linkExpressProfiler.LinkVisited = true;
		}

		private void LinkFeedback_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			string url = "mailto:davedbviewsharp@gmail.com";
			ProcessRunner pr = new ProcessRunner(url);
			pr.ShellExec(string.Empty);

			this.linkCodeplex.LinkVisited = true;
		}

		private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			LinkLabel lbl = sender as LinkLabel;
			string url = lbl.Text;
			ProcessRunner pr = new ProcessRunner(url);
			pr.ShellExec(string.Empty);
			lbl.LinkVisited = true;
		}
	}
}
